Repository navigation
Install the snappy codec so the Kafka consumer can read compressed batches - #126
Merged
Merged
Conversation
…tches
kafka-python does not negotiate compression. It has to decompress
whatever codec the producer chose, and the codec libraries are optional
extras it does not pull in. The image installed no snappy support, so
against a producer using snappy every fetch failed with:
kafka.errors.UnsupportedCodecError:
Libraries for snappy compression codec not found
This is worse than a single failed message. UnsupportedCodecError is
raised by the consumer iterator while fetching, not by consume(), so it
is outside the per-message error handling in kafka_backend(). The
exception escapes the loop, the process exits, and on restart the
consumer rejoins and re-fetches the same uncommitted batch, failing
again. Observed in a stage deployment as a crash loop that advanced the
consumer group through 13 generations in three hours without committing
an offset.
Only snappy is added here, which is what the producer in question uses.
lz4 and zstd remain unavailable and would fail the same way.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
kafka-pythondoes not negotiate compression — it has to decompress whatever codec the producer chose — and the codec libraries are optional extras it does not pull in. The image installs no snappy support, so against a producer using snappy every fetch fails:Why this is a crash loop, not a dropped message
UnsupportedCodecErroris raised by the consumer iterator while fetching, not byconsume(). That puts it outside the per-message error handling added in 16f9dbe, which only wrapsconsume():The exception escapes the loop,
finallycloses the consumer, and the process exits. On restart the consumer rejoins the group and re-fetches the same uncommitted batch, failing identically.Observed in a stage deployment as a crash loop that advanced the consumer group through 13 generations in three hours without ever committing an offset. Authentication, TLS, topic subscription and partition assignment were all healthy — only the decompression failed.
Fix
Adds
python3-snappytodocker/install-dependencies.sh.requirements.inis deliberately untouched: the Dockerfile installs RPMs and then runspip install --no-deps ., so the runtime image only sees the dnf list. Addingpython-snappyto pip would make CI build it from source and requirelibsnappy-dev.Scope
Only snappy is added, which is what the producer in question uses.
lz4andzstdremain unavailable and would fail the same way if a producer switched codec — happy to add those here too if preferred.🤖 Generated with Claude Code